/*
 * @Description: iconfont图标动态扩展
 * @Author: chendingfengmail@163.com
 * @Date: 2023-08-15 02:40:18
 * @LastEditTime: 2023-08-15 02:40:18
 * @LastEditors: chendingfengmail@163.com
 * @Reference: 
 */
export default {
  install (Vue) {
    function iconfontLoader() {
        // 读取/public/iconfonts/ 目录文件夹，递归查找文件夹下所有iconfont.css文件
        const files = require.context('/public/iconfonts/', true, /\iconfont\.css$/)
        // 以文件路径动态引入css文件
        files.keys().forEach(key => {
            const path = key.substring(2)
            let font_link = document.createElement('link')
            font_link.setAttribute('rel', 'stylesheet')
            font_link.setAttribute('type', 'text/css')
            font_link.setAttribute('href', `iconfonts/${path}`)
            document.head.appendChild(font_link)
        });
    }
    iconfontLoader()
  }
}
